<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="./../css/shengqian.css">
    <script src="./../js/shengqian.js"></script>
</head>
<body>
    <header id="header">
        <a href="./../index.html" class="back fl"></a>
        <h4>省钱控-最新优惠</h4>
        <div class="app fr">
<a href="">
    <img src="./../assets/images/header_app.png" alt="">
</a>
        </div>
    </header>
    <!--商品推荐-->
    <div class="productList">
        <ul></ul>
    </div>
<!-- 换页按钮 -->
<div class="change">
    <button class="up" disabled>上一页</button>
    <select name="" id="page">
        <option value="1">1/14</option>
        <option value="2">2/14</option>
        <option value="3">3/14</option>
        <option value="4">4/14</option>
        <option value="5">5/14</option>
        <option value="6">6/14</option>
        <option value="7">7/14</option>
        <option value="8">8/14</option>
        <option value="9">9/14</option>
        <option value="10">10/14</option>
        <option value="11">11/14</option>
        <option value="12">12/14</option>
        <option value="13">13/14</option>
        <option value="14">14/14</option>

    </select>
    <button class="down">下一页</button>
</div>
<!--底部-->
    <section id="footer">
        <div class="more">
            <a href="">更多优惠信息</a>
        </div>
        <div class="chart">
            <span class="chart_in fl">品牌排行</span>
            <span class="more fr">
                <img src="./../assets/images/more.png" alt="">
            </span>
        </div>
        <div class="login">
            <div class="container">
                <div class="ro">
                    <a href="">
                        <div class="col-xs-3">登入</div>
                    </a>
                    <a href="">
                        <div class="col-xs-4">注册</div>
                    </a>
                    <a href="">
                        <div class="col-xs-5">返回顶部</div>
                    </a>
                    <span></span>
                </div>
            </div>
        <div class="content_b">
            <p>
                <a href="#">
                    手机APP下载
                </a>
                <a href="#">
                    万锋智慧商城手机版
                </a>
                -- 掌上比价平台
            </p>
            <p>
                chst.vip:8081/crm </p>
        </div>
        </div>
            </section>
</body>

<script >
       var pl=document.querySelector(".productList")
       const xhr=new XMLHttpRequest();
   
   xhr.open("get","http://chst.vip:1234/api/getmoneyctrl?pageid",true);
   xhr.send(null);
   xhr.onreadystatechange = function(){
           if(xhr.readyState === 4){
               if(xhr.status === 200){
                   let res = JSON.parse(xhr.responseText);
                   console.log(res);
                   let regExp = /(?<=imgurl=)[^'"]*/;
                   let ele = "";
                   res.result.forEach(item => {
                       // console.log(item);
                       var img = regExp.exec(item.productImg2)[0];
                       ele += `<div productId="${item.productId}">
                               <img src="${img}" alt="">
                               <h5>${item.productName}</h5>
                               <p>${item.productPinkage}</p>
                               <span>${item.productTime}</span>
                           </div>`
                   });
                   pl.innerHTML = ele;
               }
           }
       }
       pl.onclick = function(e){
            var e = e || window.event;
            var target = e.target || e.srcElement;
            console.log(target);
            if(target.nodeName != "DIV" ){
                var _this = target.parentNode;
            }else{
                var _this = target;
            }
            var pd=_this.getAttribute("productId");
            location.href="./../xiangqingye.html?productid="+pd;
       }

</script>
</html>